package com.example.flower_shop.repository;

import com.example.flower_shop.entity.ReviewReply;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface ReviewReplyRepository extends JpaRepository<ReviewReply, Long> {
    Page<ReviewReply> findByParentReviewId(Long reviewId, Pageable pageable);

    Page<ReviewReply> findByUserId(Long userId, Pageable pageable);

    @Modifying
    @Query("DELETE FROM ReviewReply r WHERE r.parentReview.id = ?1")
    void deleteByReviewId(Long reviewId);
}